package com.taiji.test;

/**
 * 两个大数相乘
 */
public class Question_3 {
    public static String handle(String str1, String st2) {
        char char1[] = str1.toCharArray();
        char char2[] = st2.toCharArray();
        int result[] = new int[char1.length + char2.length];
        int n1[] = new int[char1.length];
        int n2[] = new int[char2.length];

        for (int i = 0; i < char1.length; i++) {
            n1[i] = char1[i] - '0';
        }
        for (int j = 0; j < char2.length; j++) {
            n2[j] = char2[j] - '0';
        }
        for (int i = 0; i < char1.length; i++) {
            for (int j = 0; j < char1.length; j++) {
                result[i + j] += n1[i] * n2[j];
            }
        }
        for (int i = result.length - 1; i > 0; i--) {
            result[i - 1] += result[i] / 10;
            result[i] = result[i] % 10;
        }
        String resultStr = "";
        for (int i = 0; i < result.length - 1; i++) {
            resultStr += "" + result[i];
        }
        return resultStr;
    }

    public static void main(String[] args) {
        //28839650403592782
        System.out.println(handle("123123123", "234234234"));
    }
}
